package com.hontech.kaltaapp.store

import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.os.Environment
import com.hontech.kaltaapp.app.AppContext
import com.hontech.kaltaapp.utils.runAsync
import java.io.File

private val PATH = File(Environment.getExternalStorageDirectory(), "store.db").path
private const val VERSION = 1
private class DbConn : SQLiteOpenHelper(AppContext, PATH, null, VERSION) {

    override fun onCreate(db: SQLiteDatabase?) {

    }

    override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {

    }
}

object Store {

    val conn = DbConn().writableDatabase

    suspend fun init() {
        runAsync {
            conn.execSQL(WaitInfo.SQL_CREATE)
            conn.execSQL(WaterInfo.SQL_CREATE)
            conn.execSQL(SteamInfo.SQL_CREATE)
            conn.execSQL(MoveSteamInfo.SQL_CREATE)
            conn.execSQL(CookingAction.SQL_CREATE)
            conn.execSQL(CookingStep.SQL_STEP_CREATE)
        }
    }

}